import java.util.ArrayList;
import java.util.Scanner;
//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {
        ArrayList<User> userList=new ArrayList<>();
        userList.add(new User("1001","小明123","金牌客户","2020.2.27",5000.0,"14432267876","xiaoming@tt.com"));
        userList.add(new User("1002","小红234","银牌客户","2021.3.4",4000.0,"13456723456","xiaohong@ww.com"));
        userList.add(new User("1003","小李345","铜牌客户","2023.7.8",2000.0,"15765219988","xiaoli@ww.com"));
        ArrayList<Product>goodsList=new ArrayList<>();
        ArrayList<Product> Car = new ArrayList<>();
        goodsList.add(new Product("001","乐事薯片","乐事公司","2024.7.10","9991",3.0,7.0,100));
        goodsList.add(new Product("002","火鸡面","三养公司","2024.7.2","4765",5.0,8.0,50));
        goodsList.add(new Product("003","小面包","盼盼公司","2024.7.20","3332",8.0,10.0,200));
        User user=new User();
        Administor admin = new Administor("admin","ynuinfo#777");
        Menu mgr=new Menu();
        Product product=new Product();
        Tools tools=new Tools();
        ShoppingCar shoppingCar=new ShoppingCar();
        Pay pay=new Pay();
        System.out.println("欢迎来到购物系统！" + "请选择您的身份：" +
                "1、管理员" +
                "2、用户" );
        Scanner reader=new Scanner(System.in);
        if(reader.nextInt()==1) {
            admin.login();
            while (true) {
                mgr.adminMenu();
                int choice1 = reader.nextInt();
                switch (choice1) {
                    case 1: {
                        mgr.adminMenu2();
                        int choice2 = reader.nextInt();
                        if (choice2 == 1) {
                            admin.passwordMng();
                        }
                        if (choice2 == 2) {
                            admin.resetUserpassword(userList);
                        }
                        break;
                    }
                    case 2: {
                        mgr.adminMenu3();
                        int choice3 = reader.nextInt();
                        if (choice3 == 1) {
                            admin.listUserInfo(userList);
                        } else if (choice3 == 2) {
                            admin.delUserInfo(userList);
                        } else if (choice3 == 3) {
                            admin.findInfo(userList);
                        }
                        break;
                    }
                    case 3: {
                        mgr.adminMenu4();
                        int choice4 = reader.nextInt();
                        if (choice4 == 1) {
                            product.listGoodsInfo(goodsList);
                        } else if (choice4 == 2) {
                            product.addInfo(goodsList);
                        } else if (choice4 == 3) {
                            product.changeGoodsInfo(goodsList);
                        } else if (choice4 == 4) {
                            product.delGoodsInfo(goodsList);
                        } else if (choice4 == 5) {
                            product.findGoodsInfo(goodsList);
                        }
                        break;
                    }
                    case 4: {
                        System.out.println("感谢使用购物管理系统！");
                        return;
                    }
                }
            }
        } else{
            mgr.userMenu();
            while (true){
                mgr.userMenu();
                int Choice=reader.nextInt();
                switch (Choice){
                    case 1: {
                        user.register();
                        break;
                    }
                    case 2:{
                        user.Login(userList);
                        break;
                    }
                    case 3:{
                        mgr.userMenu2();
                        int Choice2=reader.nextInt();
                        if(Choice2==1){
                            user.changePassword(userList);
                            break;
                        } else if (Choice2==2) {
                            user.forgetPassword(userList);
                            break;
                        }
                    }
                    case 4:{
                        mgr.userMenu3();
                        int Choice3=reader.nextInt();
                        if(Choice3==1){
                            shoppingCar.addToCar(goodsList,Car);
                        } else if (Choice3==2) {
                            shoppingCar.remove(goodsList);
                        }
                        else if(Choice3==3){
                            shoppingCar.changeNum(goodsList);
                        }
                        else if(Choice3==4) {
                            pay.payFor(Car);
                            pay.changeCount(goodsList);
                        }
                        else if(Choice3==5){
                            pay.showList();
                        }
                        else{
                            shoppingCar.showCar(Car);
                        }
                        break;
                    }
                }

            }
        }
    }
}